package com.example.controller;

import com.example.entity.Label;
import com.example.entity.LabelDTO;
import com.example.entity.Result;
import com.example.service.LabelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name = "分类标签相关接口")
@Slf4j
@RequestMapping("/label")
@CrossOrigin
public class LabelController {

    @Autowired
    private LabelService labelService;

    @Operation(summary = "新增分类标签")
    @PostMapping("/save")
    public Result save(@RequestBody LabelDTO labelDTO){
        log.info("进行新增分类标签操作：{}",labelDTO);
        labelService.save(labelDTO);
        return Result.success();
    }



    @GetMapping("/selectAll")
    @Operation(summary = "查询所有分类标签信息")
    public Result<List<Label>> selectAll(){
        log.info("查询所有分类标签数据");
        List<Label> labelList = labelService.list();
        return Result.success(labelList);
    }

}
